function ising_plot(n, isingmat)
    %根据矩阵isingmat画n*n二维方格图

    %先清空绘画区域
    %clf();

    %确定图像边界
    margin = 0.04;
    x_min = 0 ;
    x_max = n + margin;
    y_min = 0 ;
    y_max = n + margin;

    %将背景涂成黑色
    rgb = [0.0, 0.0, 0.0];
    fill([x_min, x_min, x_max, x_max],[y_min, y_max, y_max, y_min], rgb)
    hold on

    for i = 1 : n
        for j = 1 : n
            x1 = i - 1.0 + margin;
            x2 = i;
            y1 = j - 1.0 + margin;
            y2 = j;

            if (isingmat(i,j) == -1)
                rgb = [1.0, 1.0, 1.0];
            elseif (isingmat(i,j) == 1)
                rgb = [0.0, 0.0, 1.0];
            end

            fill([x1, x1, x2, x2], [y1, y2, y2, y1], rgb);
            hold on

        end
    end

%     title_string = sprintf ('%d',step);
%     title ( title_string )

    axis ( [ x_min, x_max, y_min, y_max] );
    axis equal
    axis tight
    axis off

    %hold ( 'off' );

    return
end